{extend name="common/base" /}

{block name="body"}
<div class="tx-mains">
    <ul class="tx-nav">
        <li>
            <div class="tx-z">支付宝账号</div>
            <input type="text" class="tx-y js-account" placeholder="填写支付宝账号" value="{$cashInfo.cash_account}">
        </li>
        <li>
            <div class="tx-z">支付宝实名</div>
            <input type="text" class="tx-y js-name" placeholder="填写支付宝实名" value="{$cashInfo.cash_name}">
        </li>
        <li>
            <div class="tx-z">提现金额</div>
            <input type="text" class="tx-y js-amount" placeholder="填写提现金额，最低提现金额¥100">
        </li>          
    </ul>
    <div class="tx-bott">
        {notpresent name="wallet"}
        <span class="span1">余额：¥0.00</span>
        <input type="hidden" class="tx-y js-cash" value="0">

        {else /}
        <input type="hidden" class="tx-y js-cash" value="{$wallet.cash_amount}">
        <span class="span1">余额：¥{$wallet.cash_amount}</span>

        {/notpresent}
        <span class="span2">提现收取5%的收取费</span>
    </div>
    <div class="boo-aniu"><div class="js-to-cash">立即提现</div></div>
</div>
</body>
{/block}
{block name="menu"}
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        $('.js-to-cash').on('click', function () {
            var account = $('.js-account').val();
            var name = $('.js-name').val();
            var amount = $('.js-amount').val();
            var cash = $('.js-cash').val();
          
            if (!account) {
                mui.alert('请填写支付宝账号');
                return false;
            }
            
            if (!name) {
                mui.alert('请填写支付宝实名');
                return false;
            }
            if (amount==''||amount=='0') {
                mui.alert('请填写请填写提现金额');
                return false;
            }
             if (parseFloat(amount)<100) {
                mui.alert('最提提现金额100元');
                return false;
            }
            if (parseFloat(amount)>parseFloat(cash)) {
                mui.alert('可提现余额不足');
                return false;
            }

            
            $.post("{:url('My/cash')}", {account: account, name: name, amount: parseFloat(amount)}, function (res) {
                if (res.code == '1') {
                    location.href = res.url;
                } else {
                    mui.toast(res.msg);
                }
            }, 'json');

        });
    });
</script>
{/block}